package com.lzz.controller;

import com.lzz.entity.Permission;
import com.lzz.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author zhenzhen
 * @date 2018-12-21 下午9:45
 */
@Controller
@RequestMapping(value = "/permission")
public class PermissionController {

    @Autowired
    private PermissionService permissionService;

    @GetMapping(value = "/addView")
    public String addPermissionView() {
        return "addPermission";
    }

    @PostMapping(value = "/addPermission", produces = "application/json;charset=utf-8")
    @ResponseBody
    public String addPermission(Permission permission) {
        int result = permissionService.addPermission(permission);
        return result == 1 ? "添加成功" : "添加失败";
    }

    @GetMapping(value = "/getPermission/{uuid}", produces = "application/json;charset=utf-8")
    @ResponseBody
    public Permission getPermission(@PathVariable String uuid) {
        return permissionService.getById(uuid);
    }
}
